<%@page import="java.io.FileInputStream"%>
<%@page import="java.io.File"%>
<%@page import="databank.DataBank"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<jsp:useBean id="bankVo" class="databank.DatabankVo"/>
<jsp:setProperty property="*" name="bankVo"/>

<%
out.clear();
out=pageContext.pushBody();

DataBank bank = new DataBank();
String savePath=bank.getUploadPath();
ServletContext context=this.getServletContext();

String sFilePath=savePath+"/"+bankVo.getFilename();


//파일을 읽기위한 버퍼정의
byte[] b= new byte[4096];
File file= new File(sFilePath);
FileInputStream in = new FileInputStream(sFilePath);

//클라이언트의 요청에 따른 응답정보 세팅
String mineType=getServletContext().getMimeType(sFilePath);
if(mineType==null) mineType="application/octect-stream";
response.setContentType(mineType);


//한글처리를 하기위한 요소
String Encoding = new String(bankVo.getFilename().getBytes("utf-8"),"8859_1");
Encoding=Encoding.replace("+", "%20");
//다운로드 화면이 출력
response.setHeader("Content-Disposition", "attachment;filename="+Encoding);

//지정된 경로에 파일 저장
ServletOutputStream sos= response.getOutputStream();
int read=0;

while((read = in.read(b, 0, b.length)) != -1 ){
	sos.write(b,0,read);
	
}
sos.flush();
sos.close();
in.close();


%>
</body>
</html>